#!/bin/bash

echo "🧪 数据库连接测试工具"
echo "===================="

# 测试PostgreSQL
echo "🐘 测试 PostgreSQL 连接..."
if docker exec -it std-postgres-1 pg_isready -U postgres > /dev/null 2>&1; then
    echo "✅ PostgreSQL 连接正常"
else
    echo "❌ PostgreSQL 连接失败"
fi

# 测试MySQL
echo "🐬 测试 MySQL 连接..."
if docker exec -it std-mysql-1 mysqladmin ping -u root -ppassword > /dev/null 2>&1; then
    echo "✅ MySQL 连接正常"
else
    echo "❌ MySQL 连接失败"
fi

# 测试SQL Server
echo "🗄️ 测试 SQL Server 连接..."
if docker exec -it std-sqlserver-1 /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P YourStrong@Passw0rd -Q "SELECT 1" > /dev/null 2>&1; then
    echo "✅ SQL Server 连接正常"
else
    echo "❌ SQL Server 连接失败"
fi

# 测试Redis
echo "🔴 测试 Redis 连接..."
if docker exec -it std-redis-1 redis-cli ping > /dev/null 2>&1; then
    echo "✅ Redis 连接正常"
else
    echo "❌ Redis 连接失败"
fi

echo ""
echo "📊 服务状态检查完成！" 